// 1. 导入http模块
const http = require('http');

// 2. 创建http服务
const app = http.createServer((request,response)=>{
    
    //请求对象
    // console.log(request);

    // 请求方式
    console.log(request.method); //GET

    // 获取http协议版本
    console.log(request.httpVersion); //1.1

    // 获取请求的路径 ***
    console.log(request.url); ///admin/1.html

    console.log(request.headers.host); //127.0.0.1:8080
    // 获取请求头信息
    console.log(request.headers);
    // {
    //     host: '127.0.0.1:8080',
    //     connection: 'keep-alive',
    //     'cache-control': 'max-age=0',
    //     'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"',
    //     'sec-ch-ua-mobile': '?0',
    //     'sec-ch-ua-platform': '"Windows"',
    //     'upgrade-insecure-requests': '1',
    //     'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
    //     accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    //     'sec-fetch-site': 'none',
    //     'sec-fetch-mode': 'navigate',
    //     'sec-fetch-user': '?1',
    //     'sec-fetch-dest': 'document',
    //     'accept-encoding': 'gzip, deflate, br',
    //     'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8'
    //   }

});

// 3. 开启服务的监听
// 参数：端口号 80-65530
app.listen(8080,()=>{
    console.log("启动成功8080端口");
})

// 4. 打开浏览器，输入localhost:8080，回车。
